"""
@author RansySun
@create 2020-02-20-20:45
"""


# 第一步：在项目根路径下创建一个py文件（database_router.py）
class DatabaseAppsRouter(object):
    def db_for_read(self, model, **hints):
        # 读可能去db1或者db2中读，
        return 'db_mysql'

    def db_for_write(self, model, **hints):
        # print(model)
        return 'default'

    def allow_migrate(self, db, app_label, model_name=None, **hints):
        # print(db)
        # print(app_label)
        # print(model_name)
        if app_label == 'app' and db == "db_mysql":
            return False
        return None
